******niri ii project******04/06/12clearset mem 500mset matsize 800use "/Users/christophersullivan/Documents/ND/NIRI/ii data.dta", cleargen timecount=0replace timecount=1 if time==196804replace timecount=2 if time==196805replace timecount=3 if time==196807replace timecount=4 if time==196808replace timecount=5 if time==196809replace timecount=6 if time==196810replace timecount=7 if time==196811replace timecount=8 if time==196812replace timecount=9 if time==196901replace timecount=10 if time==196902replace timecount=11 if time==196903replace timecount=12 if time==196904replace timecount=13 if time==196905replace timecount=14 if time==196906replace timecount=15 if time==196907replace timecount=16 if time==196908replace timecount=17 if time==196909replace timecount=18 if time==196910replace timecount=19 if time==196911replace timecount=20 if time==196912replace timecount=21 if time==197001replace timecount=22 if time==197002replace timecount=23 if time==197003replace timecount=24 if time==197004replace timecount=25 if time==197005replace timecount=26 if time==197006replace timecount=27 if time==197007replace timecount=28 if time==197008replace timecount=29 if time==197009replace timecount=30 if time==197010replace timecount=31 if time==197011replace timecount=32 if time==197012replace timecount=33 if time==197101replace timecount=34 if time==197102replace timecount=35 if time==197103replace timecount=36 if time==197104replace timecount=37 if time==197105replace timecount=38 if time==197106replace timecount=39 if time==197107replace timecount=40 if time==197108replace timecount=41 if time==197109replace timecount=42 if time==197110replace timecount=43 if time==197111replace timecount=44 if time==197112replace timecount=45 if time==197201replace timecount=46 if time==197202replace timecount=47 if time==197203replace timecount=48 if time==197204replace timecount=49 if time==197205replace timecount=50 if time==197206replace timecount=51 if time==197207replace timecount=52 if time==197208replace timecount=53 if time==197209replace timecount=54 if time==197210replace timecount=55 if time==197211replace timecount=56 if time==197212replace timecount=57 if time==197301replace timecount=58 if time==197302replace timecount=59 if time==197303replace timecount=60 if time==197304replace timecount=61 if time==197305replace timecount=62 if time==197306replace timecount=63 if time==197307replace timecount=64 if time==197308replace timecount=65 if time==197309replace timecount=66 if time==197310replace timecount=67 if time==197311replace timecount=68 if time==197312replace timecount=69 if time==197401replace timecount=70 if time==197402replace timecount=72 if time==197403replace timecount=73 if time==197404replace timecount=74 if time==197405replace timecount=75 if time==197406replace timecount=76 if time==197407replace timecount=77 if time==197408replace timecount=78 if time==197409replace timecount=79 if time==197410replace timecount=80 if time==197411replace timecount=81 if time==197412xtset loc timecountgen internment=0replace internment=1 if timecount>38gen bloodysun=0replace bloodysun=1 if timecount>56gen iraviolchange1=d1.iraviolgen iraviolchange3=d3.iraviolgen iraviolchange2=d2.iraviolsave "/Users/christophersullivan/Downloads/NI Data Full temp.dta", replacegen uktreat=0replace uktreat=1 if ukdead>0gen laguktreat=l1.uktreatgen lag6uktreat=l6.uktreatgen lag5uktreat=l5.uktreatgen lag4uktreat=l4.uktreatgen lag3uktreat=l3.uktreatgen lag2uktreat=l2.uktreatgen fuktreat=f1.uktreatgen f2uktreat=f2.uktreatgen f3uktreat=f3.uktreatgen f4uktreat=f4.uktreatgen f5uktreat=f5.uktreatgen f6uktreat=f6.uktreatgen treated=0replace treated=1 if laguktreat>0 | lag2uktreat>0 | lag3uktreat>0replace treated=1 if fuktreat>0 | f2uktreat>0 | fuktreat>0xi i.timecountgen tot=0replace tot=1 if fuktreat>0 | f2uktreat>0 | f2uktreat>0gen iralag=l1.iraviol******************************************************ANALYSIS 1 - ON IRA VIOLENCE*********generic cs-xt analysisxtreg iraviol uktreat iralag, fe********* diff-in-diff full sample analysis - 1 monthreplace treated=0replace treated=1 if laguktreat>0 replace treated=1 if fuktreat>0 replace tot=0replace tot=1 if fuktreat>0 replace iralag=l2.iraviolxtreg iraviol  treated tot iralag iraviolchange1 _Iti*, fe ********* diff-in-diff full sample analysis - 2 monthreplace treated=0replace treated=1 if laguktreat>0 | lag2uktreat>0 replace treated=1 if fuktreat>0 | f2uktreat>0 replace tot=0replace tot=1 if fuktreat>0 |  f2uktreat>0xtreg iraviol uktreat treated tot iralag iraviolchange2 _Iti*, fe ********* diff-in-diff full sample analysis - 3 monthreplace treated=0replace treated=1 if laguktreat>0 | lag2uktreat>0 | lag3uktreat>0replace treated=1 if fuktreat>0 | f2uktreat>0 | f3uktreat>0replace tot=0replace tot=1 if fuktreat>0 | f2uktreat>0 | f3uktreat>0xtreg iraviol uktreat treated tot iralag iraviolchange3 _Iti*, fe save "/Users/christophersullivan/Downloads/NI Data temp.dta", replace*********decreasing analysisuse "/Users/christophersullivan/Downloads/NI Data temp.dta", clearreplace iraviol=. if iraviolchange3[_n-1]>0 & loc[_n]==loc[_n-1]replace iraviol=. if iraviolchange3[_n-2]>0 & loc[_n-1]==loc[_n-2]replace iraviol=. if iraviolchange3[_n-3]>0 & loc[_n-1]==loc[_n-2]********* diff-in-diff full sample analysis - 3 monthreplace treated=0replace treated=1 if laguktreat>0 | lag2uktreat>0 | lag3uktreat>0replace treated=1 if fuktreat>0 | f2uktreat>0 | f3uktreat>0replace tot=0replace tot=1 if fuktreat>0 | f2uktreat>0 | f3uktreat>0xtreg iraviol uktreat treated tot iralag iraviolchange3 _Iti*, fe eststo model3, title(Model 3)********* diff-in-diff full sample analysis - 2 monthreplace iraviol=. if iraviolchange2[_n-1]>0 & loc[_n]==loc[_n-1]replace iraviol=. if iraviolchange2[_n-2]>0 & loc[_n-1]==loc[_n-2]replace iraviol=. if iraviolchange2[_n+1]>0 & loc==loc[_n+1]replace iraviol=. if iraviolchange2[_n+2]>0 & loc[_n+1]==loc[_n+2]replace treated=0replace treated=1 if laguktreat>0 | lag2uktreat>0 replace treated=1 if fuktreat>0 | f2uktreat>0 replace tot=0replace tot=1 if fuktreat>0 |  f2uktreat>0xtreg iraviol uktreat treated tot iralag iraviolchange2 _Iti*, fe eststo model2, title(Model 2)********* diff-in-diff full sample analysis - 1 monthuse "/Users/christophersullivan/Downloads/NI Data temp.dta", clearreplace iraviol=. if iraviolchange1[_n-1]>0 & loc[_n]==loc[_n-1]replace iraviol=. if iraviolchange1[_n+1]>0 & loc==loc[_n+1]replace treated=0replace treated=1 if laguktreat>0 replace treated=1 if fuktreat>0 replace tot=0replace tot=1 if fuktreat>0 xtreg iraviol uktreat treated tot iralag iraviolchange1 _Iti*, fe eststo model1, title(Model 1)******Generate Table IIestout model1 model2 model3 , cells(b(star fmt(%9.3f)) se(par))  stats(r2 N, fmt(%9.3f %9.0g)) style(fixed) legend label starlevels (* .05 ** .01 *** .001)*********increasing analysisuse "/Users/christophersullivan/Downloads/NI Data temp.dta", clearreplace iraviol=. if iraviolchange3[_n-1]<0 & loc[_n]==loc[_n-1]replace iraviol=. if iraviolchange3[_n-2]<0 & loc[_n-1]==loc[_n-2]replace iraviol=. if iraviolchange3[_n-3]<0 & loc[_n-1]==loc[_n-2]********* diff-in-diff full sample analysis - 3 monthreplace treated=0replace treated=1 if laguktreat>0 | lag2uktreat>0 | lag3uktreat>0replace treated=1 if fuktreat>0 | f2uktreat>0 | f3uktreat>0replace tot=0replace tot=1 if fuktreat>0 | f2uktreat>0 | f3uktreat>0xtreg iraviol uktreat treated tot iralag iraviolchange3 _Iti*, fe eststo model3, title(Model 3)********* diff-in-diff full sample analysis - 2 monthuse "/Users/christophersullivan/Downloads/NI Data temp.dta", clearreplace iraviol=. if iraviolchange2[_n-1]<0 & loc[_n]==loc[_n-1]replace iraviol=. if iraviolchange2[_n-2]<0 & loc[_n-1]==loc[_n-2]replace treated=0replace treated=1 if laguktreat>0 | lag2uktreat>0 replace treated=1 if fuktreat>0 | f2uktreat>0 replace tot=0replace tot=1 if fuktreat>0 |  f2uktreat>0xtreg iraviol uktreat treated tot iralag iraviolchange2 _Iti*, fe eststo model2, title(Model 2)********* diff-in-diff full sample analysis - 1 monthuse "/Users/christophersullivan/Downloads/NI Data temp.dta", clearreplace iraviol=. if iraviolchange1[_n-1]<0 & loc[_n]==loc[_n-1]replace iraviol=. if iraviolchange1[_n+1]<0 & loc==loc[_n+1]replace treated=0replace treated=1 if laguktreat>0 replace treated=1 if fuktreat>0 replace tot=0replace tot=1 if fuktreat>0 xtreg iraviol uktreat treated tot iralag iraviolchange1 _Iti*, fe eststo model1, title(Model 1)******Generate Table IIestout model1 model2 model3 , cells(b(star fmt(%9.3f)) se(par))  stats(r2 N, fmt(%9.3f %9.0g)) style(fixed) legend label starlevels (* .05 ** .01 *** .001)